/**
 * Created with CLion.
 * Description: 
 * User: loong
 * Date: 2025/6/16
 * Time: 22:36
 */

#ifndef STATS_H
#define STATS_H
#include "../core/Object.h"

class Actor;
class Stats : public Object
{
public:
    static Stats * AddStatsChild(Actor * _parent, float _max_health = 100.0f, float _max_mana = 100.0f, float _damage = 40.0f, float _mana_regen = 10.0f);

    void Update(float _dt) override;

    bool CanUseMana(float _mana_cost);
    void UseMana(float _mana_cost);
    void RegenMana(float _dt);
    void TakeDamage(float _damage);

    Actor * GetParent() const { return parent_; }
    void    SetParent(Actor * _parent) { parent_ = _parent; }

    float GetHealth() const { return health_; }
    void  SetHealth(float _health) { health_ = _health; }

    float GetMaxHealth() const { return max_health_; }
    void  SetMaxHealth(float _max_health) { max_health_ = _max_health; }

    float GetMana() const { return mana_; }
    void  SetMana(float _mana) { mana_ = _mana; }

    float GetMaxMana() const { return max_mana_; }
    void  SetMaxMana(float _max_mana) { max_mana_ = _max_mana; }

    float GetDamage() const { return damage_; }
    void  SetDamage(float _damage) { damage_ = _damage; }

    float GetManaRegen() const { return mana_regen_; }
    void  SetManaRegen(float _mana_regen) { mana_regen_ = _mana_regen; }

    float GetInvincibleTime() const { return invincible_time_; }
    void  SetInvincibleTime(float _invincible_time) { invincible_time_ = _invincible_time; }

    float GetInvincibleTimer() const { return invincible_timer_; }
    void  SetInvincibleTimer(float _invincible_timer) { invincible_timer_ = _invincible_timer; }

    bool IsAlive() const { return is_alive_; }
    void SetIsAlive(bool _is_alive) { is_alive_ = _is_alive; }

    bool IsInvincible() const { return is_invincible_; }
    void SetIsInvincible(bool _is_invincible) { is_invincible_ = _is_invincible; }

protected:
    Actor * parent_ {nullptr};
    float   health_ {100.0f};
    float   max_health_ {100.0f};
    float   mana_ {100.0f};
    float   max_mana_ {100.0f};
    float   damage_ {40.0f};
    float   mana_regen_ {10.0f};

    float invincible_time_ {1.5f}; // 受伤后，无敌时间有多长
    float invincible_timer_ {0.0f};// 无敌计时器
    bool  is_alive_ {true};
    bool  is_invincible_ {false};
};

#endif//STATS_H
